

using System;
using System.Collections.Generic;
using System.Text;
using DataAccessLayer;
using EntityLayer;
using DataLayer;
using System.Data;
using InfraStructureLayer;

namespace BusinessLayer
{
	public class busBlogrollLinks:BusinessBase
	{
		public busBlogrollLinks() : base()
		{
		}
		#region  Code Factory Generated Methods
		

		public DataTable SelectBlogrollLinks()
		{
			try
			{
				datBlogrollLinks insDatBlogrollLinks = new datBlogrollLinks();
				DbConnector insDbConnector = new DbConnector();
				return insDatBlogrollLinks.SelectBlogrollLinks(insDbConnector);
			}
			catch (SFException ex)
			{
				this.ErrorMessage = ex.Message;
			}
			return null;
		}
		public void SelectBlogrollLinksByBlogrollLinkId(entBlogrollLinks parEntBlogrollLinks)
		{
			try
			{
				datBlogrollLinks insDatBlogrollLinks = new datBlogrollLinks();
				DbConnector insDbConnector = new DbConnector();
				insDatBlogrollLinks.SelectBlogrollLinksByBlogrollLinkId(parEntBlogrollLinks, insDbConnector);
			}
			catch (SFException ex)
			{
				this.ErrorMessage=ex.Message;
			}
		}
		
		#endregion

        public DataTable SelectBlogrollLinksRandom()
        {
            try
            {
                datBlogrollLinks insDatBlogrollLinks = new datBlogrollLinks();
                DbConnector insDbConnector = new DbConnector();
                return insDatBlogrollLinks.SelectBlogrollLinksRandom(insDbConnector);

            }
            catch (SFException ex)
            {
                this.ErrorMessage = ex.Message;
            }
            return null;
        }
        public DataTable SelectBlogrollLinksByLanguageId()
        {
            try
            {
                datBlogrollLinks insDatBlogrollLinks = new datBlogrollLinks();
                DbConnector insDbConnector = new DbConnector();
                return insDatBlogrollLinks.SelectBlogrollLinksByLanguageId(insDbConnector);
            }
            catch (SFException ex)
            {
                this.ErrorMessage = ex.Message;
            }
            return null;
        }

        public void InsertBlogrollLinks(entBlogrollLinks parEntBlogrollLinks, List<entBlogrollLinkContents> parEntBlogrollLinkContentsInsert, List<entBlogrollLinkContents> parEntBlogrollLinkContentsUpdate, List<entBlogrollLinkContents> parEntBlogrollLinkContentsDelete)
        {
            DbConnector insDbConnector = new DbConnector();
            try
            {

                insDbConnector.BeginTransaction();
                datBlogrollLinks insDatBlogrollLinks = new datBlogrollLinks();
                insDatBlogrollLinks.InsertBlogrollLinks(parEntBlogrollLinks, insDbConnector);
                datBlogrollLinkContents insDatBlogrollLinkContents = new datBlogrollLinkContents();
                foreach (entBlogrollLinkContents insEntBlogrollLinkContents in parEntBlogrollLinkContentsInsert)
                {
                    insEntBlogrollLinkContents.BlogrollLinkId = parEntBlogrollLinks.BlogrollLinkId;
                    insDatBlogrollLinkContents.InsertBlogrollLinkContents(insEntBlogrollLinkContents, insDbConnector);
                }
                foreach (entBlogrollLinkContents insEntBlogrollLinkContents in parEntBlogrollLinkContentsUpdate)
                {
                    insEntBlogrollLinkContents.BlogrollLinkId = parEntBlogrollLinks.BlogrollLinkId;
                    insDatBlogrollLinkContents.UpdateBlogrollLinkContentsByBlogrollLinkContentId(insEntBlogrollLinkContents, insDbConnector);
                }
                foreach (entBlogrollLinkContents insEntBlogrollLinkContents in parEntBlogrollLinkContentsDelete)
                {
                    insDatBlogrollLinkContents.DeleteBlogrollLinkContentsByBlogrollLinkContentId(insEntBlogrollLinkContents, insDbConnector);
                }
                insDbConnector.CommitTransaction();
            }
            catch (SFException ex)
            {
                insDbConnector.RollbackTransaction();
                this.ErrorMessage = ex.Message;
            }
            catch (Exception ex)
            {
                insDbConnector.RollbackTransaction();
                throw new SFUnHandledException(ex);
            }
        }
        public void UpdateBlogrollLinksByBlogrollLinkId(entBlogrollLinks parEntBlogrollLinks, List<entBlogrollLinkContents> parEntBlogrollLinkContentsInsert, List<entBlogrollLinkContents> parEntBlogrollLinkContentsUpdate, List<entBlogrollLinkContents> parEntBlogrollLinkContentsDelete)
        {
            DbConnector insDbConnector = new DbConnector();
            try
            {

                insDbConnector.BeginTransaction();
                datBlogrollLinks insDatBlogrollLinks = new datBlogrollLinks();
                insDatBlogrollLinks.UpdateBlogrollLinksByBlogrollLinkId(parEntBlogrollLinks, insDbConnector);
                datBlogrollLinkContents insDatBlogrollLinkContents = new datBlogrollLinkContents();
                foreach (entBlogrollLinkContents insEntBlogrollLinkContents in parEntBlogrollLinkContentsInsert)
                {
                    insEntBlogrollLinkContents.BlogrollLinkId = parEntBlogrollLinks.BlogrollLinkId;
                    insDatBlogrollLinkContents.InsertBlogrollLinkContents(insEntBlogrollLinkContents, insDbConnector);
                }
                foreach (entBlogrollLinkContents insEntBlogrollLinkContents in parEntBlogrollLinkContentsUpdate)
                {
                    insEntBlogrollLinkContents.BlogrollLinkId = parEntBlogrollLinks.BlogrollLinkId;
                    insDatBlogrollLinkContents.UpdateBlogrollLinkContentsByBlogrollLinkContentId(insEntBlogrollLinkContents, insDbConnector);
                }
                foreach (entBlogrollLinkContents insEntBlogrollLinkContents in parEntBlogrollLinkContentsDelete)
                {
                    insDatBlogrollLinkContents.DeleteBlogrollLinkContentsByBlogrollLinkContentId(insEntBlogrollLinkContents, insDbConnector);
                }
                insDbConnector.CommitTransaction();
            }
            catch (SFException ex)
            {
                insDbConnector.RollbackTransaction();
                this.ErrorMessage = ex.Message;
            }
            catch (Exception ex)
            {
                insDbConnector.RollbackTransaction();
                throw new SFUnHandledException(ex);
            }
        }
        public void DeleteBlogrollLinksByBlogrollLinkId(entBlogrollLinks parEntBlogrollLinks)
        {
            DbConnector insDbConnector = new DbConnector();
            try
            {

                insDbConnector.BeginTransaction();
                datBlogrollLinkContents insDatBlogrollLinkContents = new datBlogrollLinkContents();
                entBlogrollLinkContents insEntBlogrollLinkContents = new entBlogrollLinkContents();
                insEntBlogrollLinkContents.BlogrollLinkId = parEntBlogrollLinks.BlogrollLinkId;
                insDatBlogrollLinkContents.DeleteBlogrollLinkContentsByBlogrollLinkId(insEntBlogrollLinkContents, insDbConnector);

                datBlogrollLinks insDatBlogrollLinks = new datBlogrollLinks();
                insDatBlogrollLinks.DeleteBlogrollLinksByBlogrollLinkId(parEntBlogrollLinks, insDbConnector);


                insDbConnector.CommitTransaction();
            }
            catch (SFException ex)
            {
                insDbConnector.RollbackTransaction();
                this.ErrorMessage = ex.Message;
            }
            catch (Exception ex)
            {
                insDbConnector.RollbackTransaction();
                throw new SFUnHandledException(ex);
            }
        }
	}
}